home *** CD-ROM | disk | FTP | other *** search
- #!/local/bin/perl
- # ftpget. (C) S.Maffeis 1992. maffeis@ifi.unizh.ch
-
- require 'ftp.pl';
-
- sub usage{
- print STDERR
- "usage: ftpget remotehost [username passwd] remotefile localfile\n";
- };
-
- if(scalar(@ARGV) != 3 && scalar(@ARGV) != 5){ &usage(); exit 1;};
-
- if(scalar(@ARGV) == 3){
- chop($hostname = `/bin/hostname`);
-
- if(!&ftp'open(@ARGV[0], 21, 0, 1)){
- print STDERR "cannot open connection to @ARGV[0]\n";
- exit 1;
- };
- if(!&ftp'login("anonymous", "ftpget@$hostname")){
- print STDERR "cannot login as anonymous\n";
- exit 1;
- };
- if( ! &ftp'type('I')){
- print STDERR "cannot set file type to I\n";
- exit 1;
- };
- if(!&ftp'get(@ARGV[1], @ARGV[2])){
- print STDERR "@ARGV[1]: file not found\n";
- exit 1;
- };
- &ftp'quit();
-
- exit 0;
- };
-
- if(!&ftp'open(@ARGV[0], 21, 1, 1)){
- print STDERR "cannot open connection to @ARGV[0]\n";
- exit 1;
- };
- if(!&ftp'login(@ARGV[1], @ARGV[2])){
- print STDERR "cannot login as @ARGV[1]\n";
- exit 1;
- };
- if( ! &ftp'type('I')){
- print STDERR "cannot set file type to I\n";
- exit 1;
- };
- if(!&ftp'get(@ARGV[3], @ARGV[4])){
- print STDERR "@ARGV[3]: file not found\n";
- exit 1;
- };
- &ftp'quit();
-
- exit 0;
-
-